/*
 * intnumberobject.cpp
 *
 *  Created on: Oct 27, 2009
 *      Author: price
 */

#include "includes/realnumberobject.h"
namespace templatipus {

TRealNumberObject::TRealNumberObject() :
	TNumberObject(), internalValue(0) {

}

TRealNumberObject::TRealNumberObject(const TemplateObject &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TRealNumberObject::TRealNumberObject(const int8 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TRealNumberObject::TRealNumberObject(const int16 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TRealNumberObject::TRealNumberObject(const int32 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TRealNumberObject::TRealNumberObject(const int64 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TRealNumberObject::TRealNumberObject(const float32 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TRealNumberObject::TRealNumberObject(const float64 &rhs) :
	TNumberObject(rhs), internalValue(rhs) {

}

TRealNumberObject::TRealNumberObject(const std::wstring& rhs) :
	TNumberObject(rhs) {
	swscanf(rhs.c_str(),L"%lf" , &this->internalValue);
}

TRealNumberObject::TRealNumberObject(const std::string& rhs) :
TNumberObject(rhs) {
	sscanf(rhs.c_str(), "%lf", &this->internalValue);
}

TRealNumberObject::TRealNumberObject(const unicodePtr rhs) :
TNumberObject(rhs) {
	swscanf(rhs,L"%lf" , &this->internalValue);
}

TRealNumberObject::TRealNumberObject(const utf8Ptr rhs) :
TNumberObject(rhs) {
	sscanf(rhs, "%lf", &this->internalValue);
}

TRealNumberObject::~TRealNumberObject() {

}

TRealNumberObject TRealNumberObject::operator +(const TemplateObject &other){
	TRealNumberObject result = *this;
	result += other;
	return result;
}
TRealNumberObject TRealNumberObject::operator -(const TemplateObject &other) {
	TRealNumberObject result = *this;
	result -= other;
	return result;
}

TRealNumberObject TRealNumberObject::operator *(const TemplateObject &other) {
	TRealNumberObject result = *this;
	result *= other;
	return result;
}

TRealNumberObject TRealNumberObject::operator /(const TemplateObject &other) {
	TRealNumberObject result = *this;
	result /= other;
	return result;
}

const TemplateObject& TRealNumberObject::operator ++() {
	this->internalValue++;
	return *this;
}

const TemplateObject& TRealNumberObject::operator --() {
	this->internalValue--;
	return *this;
}

const TemplateObject& TRealNumberObject::operator +=(
		const TemplateObject &other) {
	this->internalValue += ((float64) other);
	return *this;
}

const TemplateObject& TRealNumberObject::operator -=(
		const TemplateObject &other) {
	this->internalValue -= ((float64) other);
	return *this;
}

const TemplateObject& TRealNumberObject::operator *=(
		const TemplateObject &other) {
	this->internalValue *= ((float64) other);
	return *this;
}

const TemplateObject& TRealNumberObject::operator /=(
		const TemplateObject &other) {
	this->internalValue /= ((float64) other);
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const TemplateObject &other) {
	if (this != &other) {
		this->internalValue = (float64) other;
	}
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const int8 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const int16 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const int32 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const int64 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const float32 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const float64 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const std::wstring &other) {
	swscanf(other.c_str(), L"%lf", &this->internalValue);
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const std::string &other) {
	sscanf(other.c_str(), "%lf", &this->internalValue);
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const unicodePtr other) {
	swscanf(other, L"%lf", &this->internalValue);
	return *this;
}

TemplateObject& TRealNumberObject::operator=(const utf8Ptr other) {
	sscanf(other, "%lf", &this->internalValue);
	return *this;
}

tbool TRealNumberObject::operator ==(const TemplateObject &other) const {
	return (this->internalValue == (float64) other);
}

tbool TRealNumberObject::operator !=(const TemplateObject &other) const {
	return !(*this == other);
}

tbool TRealNumberObject::operator >(const TemplateObject &other) const {
	return (this->internalValue > (float64) other);
}

tbool TRealNumberObject::operator <(const TemplateObject &other) const {
	return !(*this > other);
}

tbool TRealNumberObject::operator >=(const TemplateObject &other) const {
	return (this->internalValue >= (float64) other);
}

tbool TRealNumberObject::operator <=(const TemplateObject &other) const {
	return !(*this >= other);
}

tbool TRealNumberObject::operator &&(const TemplateObject &other) const {
	return (this->internalValue && (float64) other);
}

tbool TRealNumberObject::operator ||(const TemplateObject &other) const {
	return (this->internalValue || (float64) other);
}

//String stuff
TRealNumberObject::operator std::string() const {
	std::ostringstream result;
	result << this->internalValue;
	return result.str();
}
TRealNumberObject::operator std::wstring() const {
	std::wostringstream result;
	result << this->internalValue;
	return result.str();
}

//Conversion operators
			//Number
			TRealNumberObject::operator int8() const {
				return this->internalValue;
			}
			TRealNumberObject::operator uint8() const {
				return (uint8) this->internalValue;
			}
			TRealNumberObject::operator int16() const {
				return (int16) this->internalValue;
			}
			TRealNumberObject::operator uint16() const {
				return (uint16) this->internalValue;
			}
			TRealNumberObject::operator int32() const {
				return (int32) this->internalValue;
			}
			TRealNumberObject::operator uint32() const {
				return (uint32) this->internalValue;
			}
			TRealNumberObject::operator int64() const {
				return (int64) this->internalValue;
			}
			TRealNumberObject::operator uint64() const {
				return (uint64) this->internalValue;
			}
			TRealNumberObject::operator float32() const {
				return (float32) this->internalValue;
			}
			TRealNumberObject::operator float64() const {
				return (float64) this->internalValue;
			}

			TRealNumberObject::operator tbool() const {
				return (tbool) this->internalValue;
			}
		}
